package o;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

public final class aad {
    private static final ConcurrentMap<String, sa> ॱ = new ConcurrentHashMap();

    @NonNull
    public static sa ॱ(@NonNull Context context) {
        String packageName = context.getPackageName();
        sa saVar = (sa) ॱ.get(packageName);
        if (saVar != null) {
            return saVar;
        }
        sa ˋ = ˋ(context);
        saVar = (sa) ॱ.putIfAbsent(packageName, ˋ);
        if (saVar == null) {
            return ˋ;
        }
        return saVar;
    }

    @NonNull
    private static sa ˋ(@NonNull Context context) {
        return new aai(ˏ(ˎ(context)));
    }

    @NonNull
    private static String ˏ(@Nullable PackageInfo packageInfo) {
        if (packageInfo != null) {
            return String.valueOf(packageInfo.versionCode);
        }
        return UUID.randomUUID().toString();
    }

    @Nullable
    private static PackageInfo ˎ(@NonNull Context context) {
        try {
            return context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
        } catch (Throwable e) {
            Log.e("AppVersionSignature", "Cannot resolve info for" + context.getPackageName(), e);
            return null;
        }
    }
}
